package com.wzcl.app.controller;

import com.wzcl.app.model.common.RVO;
import com.wzcl.app.model.dto.CatalogEvaluateScoreDto;
import com.wzcl.app.service.CatalogEvaluateScoreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author beingven
 * @Description TODO
 * @createTime 2021年01月13日 17:04:00
 */
@Api(value = "作文课章节评分记录controller", tags = {"作文课章节评分记录相关接口"})
@RestController
@RequestMapping("/catalogEvaluate")
public class CatalogEvaluateScoreController {
    @Resource
    private CatalogEvaluateScoreService catalogEvaluateScoreService;

    @ApiOperation("创建章节学习记录")
    @PostMapping("/create")
    public RVO create(@RequestBody CatalogEvaluateScoreDto catalogEvaluateScoreDto){
        return RVO.success(catalogEvaluateScoreService.create(catalogEvaluateScoreDto));
    }

    @ApiOperation("获取课程下所有章节评分")
    @GetMapping("/retrieve/catalog/{courseId}")
    public RVO retrieveByCourseId(@PathVariable Integer courseId){
        return catalogEvaluateScoreService.getCatalogStarFromCourse(courseId);
    }

    @ApiOperation("获取章节下所有任务评分")
    @GetMapping("/retrieve/task/{catalogId}")
    public RVO retrieveByCatalogId(@PathVariable Integer catalogId){
        return catalogEvaluateScoreService.getTaskStarFromCatalog(catalogId);
    }
}